package CAPA_INTERFAZ_DE_USUARIO;

import java.awt.Dimension;
import javax.swing.JOptionPane;

public class IU_BUS_MOD_PROD extends IU_BUSCAR_PRODUCTO {
    
    public IU_BUS_MOD_PROD() {
        initComponents();
        this.getLbl_titulo().setText("MODIFICAR PRODUCTO");
        this.getBtn_buscar().setVisible(false);
        this.btn_buscar.setBounds(this.getBtn_buscar().getBounds());
        this.setMinimumSize(new Dimension (610, 190));
        this.add(this.btn_buscar);                                 
        this.add(this.getF());
        this.pack();                         
    }
   
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btn_buscar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setPreferredSize(new java.awt.Dimension(630, 172));
        setResizable(false);

        btn_buscar.setFont(new java.awt.Font("Cambria", 0, 14)); // NOI18N
        btn_buscar.setForeground(new java.awt.Color(0, 0, 102));
        btn_buscar.setText("BUSCAR");
        btn_buscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_buscarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(286, Short.MAX_VALUE)
                .addComponent(btn_buscar)
                .addGap(241, 241, 241))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(117, Short.MAX_VALUE)
                .addComponent(btn_buscar)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btn_buscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_buscarActionPerformed
        if (getCbx_modelo().getSelectedItem()==null)
        {
            JOptionPane.showMessageDialog(null,"El producto a modificar no existe","ERROR",JOptionPane.ERROR_MESSAGE);
        }
        else
        {                           
            getObj_producto().getTipo_prod().setDesc_tipo_producto(String.valueOf(getCbx_tipoproducto().getSelectedItem()));
            getObj_producto().getModelo().setDesc_modelo(String.valueOf(getCbx_modelo().getSelectedItem()));
            getObj_producto().getModelo().getMarca().setNombre_marca(String.valueOf(getCbx_marca().getSelectedItem()));                       
            
            this.getObj_ln().buscarprod(this.getObj_producto());
            IU_MODIFICACION_PRODUCTO obj_iump =new IU_MODIFICACION_PRODUCTO(this.getObj_producto());                        
            obj_iump.show();            
            this.dispose();            
        }
    }//GEN-LAST:event_btn_buscarActionPerformed
    
    public static void main(String args[]) {        
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(IU_BUS_MOD_PROD.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(IU_BUS_MOD_PROD.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(IU_BUS_MOD_PROD.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(IU_BUS_MOD_PROD.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>        
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new IU_BUS_MOD_PROD().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btn_buscar;
    // End of variables declaration//GEN-END:variables
}